//
//  PlugInSwitcher.h
//  WSPluginSwitcher
//
//  Created by Marc Bauer on 17.01.09.
//  Copyright 2009 nesiumdotcom. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "FlashPlugInVO.h"
#import "Worker.h"
#import "ThreadedHelper.h"
#import "NSError+AlertExtensions.h"

#define kWSPluginSwitcherErrorDomain @"WSPluginSwitcherErrorDomain"
#define kDefaultErrorTitle @"Could not switch your PlugIn!"

@protocol PlugInSwitcherDelegate;

@interface PlugInSwitcher : NSObject <WorkerDelegate>
{
	NSObject <PlugInSwitcherDelegate> *m_delegate;
	NSMutableArray *m_queue;
	NSMapTable *m_plugInFiles;
	FlashPlugInVO *m_currentPlugIn;
	BOOL m_authentificationRequired;
	BOOL m_isSwitching;
	NSConnection *m_connection;
	id m_workerTask;
	Worker *m_worker;
	AuthorizationRef m_authorization;
}
@property (nonatomic, assign) NSObject <PlugInSwitcherDelegate> *delegate;

- (void)addPlugInToQueue:(FlashPlugInVO *)plugIn withTargetDirectory:(NSString *)path;
- (void)beginSwitching;

- (oneway void)worker:(out byref Worker *)worker didCopyFile:(out bycopy NSString *)sourceFile;
- (oneway void)worker:(out byref Worker *)worker didFailWithError:(NSError *)error;
- (oneway void)workerDidCompleteCopying:(in byref Worker *)worker;
@end

@protocol PlugInSwitcherDelegate
- (void)plugInSwitcher:(PlugInSwitcher *)switcher didSwitchPlugIn:(FlashPlugInVO *)plugIn;
- (void)plugInSwitcherDidSwitchPlugIns:(PlugInSwitcher *)switcher;
- (void)plugInSwitcher:(PlugInSwitcher *)switcher didFailWithError:(NSError *)error;
@end